
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta charset="utf-8" />
    <title>Python Initialization Configuration &#8212; Python 3.8.13 documentation</title><meta name="viewport" content="width=device-width, initial-scale=1.0">
    
    <link rel="stylesheet" href="../_static/pydoctheme.css?2022.1" type="text/css" />
    <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
    
    <script id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
    <script src="../_static/jquery.js"></script>
    <script src="../_static/underscore.js"></script>
    <script src="../_static/doctools.js"></script>
    <script src="../_static/language_data.js"></script>
    
    <script src="../_static/sidebar.js"></script>
    
    <link rel="search" type="application/opensearchdescription+xml"
          title="Search within Python 3.8.13 documentation"
          href="../_static/opensearch.xml"/>
    <link rel="author" title="About these documents" href="../about.html" />
    <link rel="index" title="Index" href="../genindex.html" />
    <link rel="search" title="Search" href="../search.html" />
    <link rel="copyright" title="Copyright" href="../copyright.html" />
    <link rel="next" title="Memory Management" href="memory.html" />
    <link rel="prev" title="Initialization, Finalization, and Threads" href="init.html" />
    <link rel="canonical" href="https://docs.python.org/3/c-api/init_config.html" />
    
      
    

    
    <style>
      @media only screen {
        table.full-width-table {
            width: 100%;
        }
      }
    </style>
<link rel="shortcut icon" type="image/png" href="../_static/py.svg" />
            <script type="text/javascript" src="../_static/copybutton.js"></script>
            <script type="text/javascript" src="../_static/menu.js"></script> 

  </head>
<body>
<div class="mobile-nav">
    <input type="checkbox" id="menuToggler" class="toggler__input" aria-controls="navigation"
           aria-pressed="false" aria-expanded="false" role="button" aria-label="Menu" />
    <label for="menuToggler" class="toggler__label">
        <span></span>
    </label>
    <nav class="nav-content" role="navigation">
         <a href="https://www.python.org/" class="nav-logo">
             <img src="../_static/py.svg" alt="Logo"/>
         </a>
        <div class="version_switcher_placeholder"></div>
        <form role="search" class="search" action="../search.html" method="get">
            <svg xmlns="http://www.w3.org/2000/svg" width="20" height="20" viewBox="0 0 24 24" class="search-icon">
                <path fill-rule="nonzero"
                        d="M15.5 14h-.79l-.28-.27a6.5 6.5 0 001.48-5.34c-.47-2.78-2.79-5-5.59-5.34a6.505 6.505 0 00-7.27 7.27c.34 2.8 2.56 5.12 5.34 5.59a6.5 6.5 0 005.34-1.48l.27.28v.79l4.25 4.25c.41.41 1.08.41 1.49 0 .41-.41.41-1.08 0-1.49L15.5 14zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z" fill="#444"></path>
            </svg>
            <input type="text" name="q" aria-label="Quick search"/>
            <input type="submit" value="Go"/>
        </form>
    </nav>
    <div class="menu-wrapper">
        <nav class="menu" role="navigation" aria-label="main navigation">
            <div class="language_switcher_placeholder"></div>
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Python Initialization Configuration</a><ul>
<li><a class="reference internal" href="#pywidestringlist">PyWideStringList</a></li>
<li><a class="reference internal" href="#pystatus">PyStatus</a></li>
<li><a class="reference internal" href="#pypreconfig">PyPreConfig</a></li>
<li><a class="reference internal" href="#preinitialization-with-pypreconfig">Preinitialization with PyPreConfig</a></li>
<li><a class="reference internal" href="#pyconfig">PyConfig</a></li>
<li><a class="reference internal" href="#initialization-with-pyconfig">Initialization with PyConfig</a></li>
<li><a class="reference internal" href="#isolated-configuration">Isolated Configuration</a></li>
<li><a class="reference internal" href="#python-configuration">Python Configuration</a></li>
<li><a class="reference internal" href="#path-configuration">Path Configuration</a></li>
<li><a class="reference internal" href="#py-runmain">Py_RunMain()</a></li>
<li><a class="reference internal" href="#multi-phase-initialization-private-provisional-api">Multi-Phase Initialization Private Provisional API</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="init.html"
                        title="previous chapter">Initialization, Finalization, and Threads</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="memory.html"
                        title="next chapter">Memory Management</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">Report a Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/3.8/Doc/c-api/init_config.rst"
            rel="nofollow">Show Source
        </a>
      </li>
    </ul>
  </div>
        </nav>
    </div>
</div>

  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="memory.html" title="Memory Management"
             accesskey="N">next</a> |</li>
        <li class="right" >
          <a href="init.html" title="Initialization, Finalization, and Threads"
             accesskey="P">previous</a> |</li>

          <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
          <li><a href="https://www.python.org/">Python</a> &#187;</li>
          <li class="switchers">
            <div class="language_switcher_placeholder"></div>
            <div class="version_switcher_placeholder"></div>
          </li>
          <li>
              
          </li>
    <li id="cpython-language-and-version">
      <a href="../index.html">3.8.13 Documentation</a> &#187;
    </li>

          <li class="nav-item nav-item-1"><a href="index.html" accesskey="U">Python/C API Reference Manual</a> &#187;</li>
                <li class="right">
                    

    <div class="inline-search" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" aria-label="Quick search" type="text" name="q" />
          <input type="submit" value="Go" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
                     |
                </li>
            
      </ul>
    </div>    

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          <div class="body" role="main">
            
  <div class="section" id="python-initialization-configuration">
<span id="init-config"></span><h1>Python Initialization Configuration<a class="headerlink" href="#python-initialization-configuration" title="Permalink to this headline">¶</a></h1>
<div class="versionadded">
<p><span class="versionmodified added">New in version 3.8.</span></p>
</div>
<p>Structures:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#c.PyConfig" title="PyConfig"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyConfig</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyPreConfig" title="PyPreConfig"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyPreConfig</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyStatus" title="PyStatus"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyStatus</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyWideStringList" title="PyWideStringList"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyWideStringList</span></code></a></p></li>
</ul>
<p>Functions:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#c.PyConfig_Clear" title="PyConfig_Clear"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Clear()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig_InitIsolatedConfig" title="PyConfig_InitIsolatedConfig"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_InitIsolatedConfig()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig_InitPythonConfig" title="PyConfig_InitPythonConfig"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_InitPythonConfig()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig_Read" title="PyConfig_Read"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_Read()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig_SetArgv" title="PyConfig_SetArgv"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_SetArgv()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig_SetBytesArgv" title="PyConfig_SetBytesArgv"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_SetBytesArgv()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig_SetBytesString" title="PyConfig_SetBytesString"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_SetBytesString()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig_SetString" title="PyConfig_SetString"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_SetString()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig_SetWideStringList" title="PyConfig_SetWideStringList"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_SetWideStringList()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyPreConfig_InitIsolatedConfig" title="PyPreConfig_InitIsolatedConfig"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyPreConfig_InitIsolatedConfig()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyPreConfig_InitPythonConfig" title="PyPreConfig_InitPythonConfig"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyPreConfig_InitPythonConfig()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyStatus_Error" title="PyStatus_Error"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyStatus_Error()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyStatus_Exception" title="PyStatus_Exception"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyStatus_Exception()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyStatus_Exit" title="PyStatus_Exit"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyStatus_Exit()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyStatus_IsError" title="PyStatus_IsError"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyStatus_IsError()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyStatus_IsExit" title="PyStatus_IsExit"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyStatus_IsExit()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyStatus_NoMemory" title="PyStatus_NoMemory"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyStatus_NoMemory()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyStatus_Ok" title="PyStatus_Ok"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyStatus_Ok()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyWideStringList_Append" title="PyWideStringList_Append"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyWideStringList_Append()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyWideStringList_Insert" title="PyWideStringList_Insert"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyWideStringList_Insert()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.Py_ExitStatusException" title="Py_ExitStatusException"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_ExitStatusException()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.Py_InitializeFromConfig" title="Py_InitializeFromConfig"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_InitializeFromConfig()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.Py_PreInitialize" title="Py_PreInitialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_PreInitialize()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.Py_PreInitializeFromArgs" title="Py_PreInitializeFromArgs"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_PreInitializeFromArgs()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.Py_PreInitializeFromBytesArgs" title="Py_PreInitializeFromBytesArgs"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_PreInitializeFromBytesArgs()</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.Py_RunMain" title="Py_RunMain"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_RunMain()</span></code></a></p></li>
</ul>
<p>The preconfiguration (<code class="docutils literal notranslate"><span class="pre">PyPreConfig</span></code> type) is stored in
<code class="docutils literal notranslate"><span class="pre">_PyRuntime.preconfig</span></code> and the configuration (<code class="docutils literal notranslate"><span class="pre">PyConfig</span></code> type) is stored in
<code class="docutils literal notranslate"><span class="pre">PyInterpreterState.config</span></code>.</p>
<p>See also <a class="reference internal" href="init.html#initialization"><span class="std std-ref">Initialization, Finalization, and Threads</span></a>.</p>
<div class="admonition seealso">
<p class="admonition-title">See also</p>
<p><span class="target" id="index-0"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0587"><strong>PEP 587</strong></a> “Python Initialization Configuration”.</p>
</div>
<div class="section" id="pywidestringlist">
<h2>PyWideStringList<a class="headerlink" href="#pywidestringlist" title="Permalink to this headline">¶</a></h2>
<dl class="type">
<dt id="c.PyWideStringList">
<code class="sig-name descname">PyWideStringList</code><a class="headerlink" href="#c.PyWideStringList" title="Permalink to this definition">¶</a></dt>
<dd><p>List of <code class="docutils literal notranslate"><span class="pre">wchar_t*</span></code> strings.</p>
<p>If <em>length</em> is non-zero, <em>items</em> must be non-<code class="docutils literal notranslate"><span class="pre">NULL</span></code> and all strings must be
non-<code class="docutils literal notranslate"><span class="pre">NULL</span></code>.</p>
<p>Methods:</p>
<dl class="function">
<dt id="c.PyWideStringList_Append">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">PyWideStringList_Append</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyWideStringList" title="PyWideStringList">PyWideStringList</a><em> *list</em>, const wchar_t<em> *item</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyWideStringList_Append" title="Permalink to this definition">¶</a></dt>
<dd><p>Append <em>item</em> to <em>list</em>.</p>
<p>Python must be preinitialized to call this function.</p>
</dd></dl>

<dl class="function">
<dt id="c.PyWideStringList_Insert">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">PyWideStringList_Insert</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyWideStringList" title="PyWideStringList">PyWideStringList</a><em> *list</em>, Py_ssize_t<em> index</em>, const wchar_t<em> *item</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyWideStringList_Insert" title="Permalink to this definition">¶</a></dt>
<dd><p>Insert <em>item</em> into <em>list</em> at <em>index</em>.</p>
<p>If <em>index</em> is greater than or equal to <em>list</em> length, append <em>item</em> to
<em>list</em>.</p>
<p><em>index</em> must be greater than or equal to 0.</p>
<p>Python must be preinitialized to call this function.</p>
</dd></dl>

<p>Structure fields:</p>
<dl class="member">
<dt id="c.PyWideStringList.length">
Py_ssize_t <code class="sig-name descname">length</code><a class="headerlink" href="#c.PyWideStringList.length" title="Permalink to this definition">¶</a></dt>
<dd><p>List length.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyWideStringList.items">
wchar_t** <code class="sig-name descname">items</code><a class="headerlink" href="#c.PyWideStringList.items" title="Permalink to this definition">¶</a></dt>
<dd><p>List items.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="pystatus">
<h2>PyStatus<a class="headerlink" href="#pystatus" title="Permalink to this headline">¶</a></h2>
<dl class="type">
<dt id="c.PyStatus">
<code class="sig-name descname">PyStatus</code><a class="headerlink" href="#c.PyStatus" title="Permalink to this definition">¶</a></dt>
<dd><p>Structure to store an initialization function status: success, error
or exit.</p>
<p>For an error, it can store the C function name which created the error.</p>
<p>Structure fields:</p>
<dl class="member">
<dt id="c.PyStatus.exitcode">
int <code class="sig-name descname">exitcode</code><a class="headerlink" href="#c.PyStatus.exitcode" title="Permalink to this definition">¶</a></dt>
<dd><p>Exit code. Argument passed to <code class="docutils literal notranslate"><span class="pre">exit()</span></code>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyStatus.err_msg">
const char *<code class="sig-name descname">err_msg</code><a class="headerlink" href="#c.PyStatus.err_msg" title="Permalink to this definition">¶</a></dt>
<dd><p>Error message.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyStatus.func">
const char *<code class="sig-name descname">func</code><a class="headerlink" href="#c.PyStatus.func" title="Permalink to this definition">¶</a></dt>
<dd><p>Name of the function which created an error, can be <code class="docutils literal notranslate"><span class="pre">NULL</span></code>.</p>
</dd></dl>

<p>Functions to create a status:</p>
<dl class="function">
<dt id="c.PyStatus_Ok">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">PyStatus_Ok</code><span class="sig-paren">(</span>void<span class="sig-paren">)</span><a class="headerlink" href="#c.PyStatus_Ok" title="Permalink to this definition">¶</a></dt>
<dd><p>Success.</p>
</dd></dl>

<dl class="function">
<dt id="c.PyStatus_Error">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">PyStatus_Error</code><span class="sig-paren">(</span>const char<em> *err_msg</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyStatus_Error" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialization error with a message.</p>
</dd></dl>

<dl class="function">
<dt id="c.PyStatus_NoMemory">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">PyStatus_NoMemory</code><span class="sig-paren">(</span>void<span class="sig-paren">)</span><a class="headerlink" href="#c.PyStatus_NoMemory" title="Permalink to this definition">¶</a></dt>
<dd><p>Memory allocation failure (out of memory).</p>
</dd></dl>

<dl class="function">
<dt id="c.PyStatus_Exit">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">PyStatus_Exit</code><span class="sig-paren">(</span>int<em> exitcode</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyStatus_Exit" title="Permalink to this definition">¶</a></dt>
<dd><p>Exit Python with the specified exit code.</p>
</dd></dl>

<p>Functions to handle a status:</p>
<dl class="function">
<dt id="c.PyStatus_Exception">
int <code class="sig-name descname">PyStatus_Exception</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a><em> status</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyStatus_Exception" title="Permalink to this definition">¶</a></dt>
<dd><p>Is the status an error or an exit? If true, the exception must be
handled; by calling <a class="reference internal" href="#c.Py_ExitStatusException" title="Py_ExitStatusException"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_ExitStatusException()</span></code></a> for example.</p>
</dd></dl>

<dl class="function">
<dt id="c.PyStatus_IsError">
int <code class="sig-name descname">PyStatus_IsError</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a><em> status</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyStatus_IsError" title="Permalink to this definition">¶</a></dt>
<dd><p>Is the result an error?</p>
</dd></dl>

<dl class="function">
<dt id="c.PyStatus_IsExit">
int <code class="sig-name descname">PyStatus_IsExit</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a><em> status</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyStatus_IsExit" title="Permalink to this definition">¶</a></dt>
<dd><p>Is the result an exit?</p>
</dd></dl>

<dl class="function">
<dt id="c.Py_ExitStatusException">
void <code class="sig-name descname">Py_ExitStatusException</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a><em> status</em><span class="sig-paren">)</span><a class="headerlink" href="#c.Py_ExitStatusException" title="Permalink to this definition">¶</a></dt>
<dd><p>Call <code class="docutils literal notranslate"><span class="pre">exit(exitcode)</span></code> if <em>status</em> is an exit. Print the error
message and exit with a non-zero exit code if <em>status</em> is an error.  Must
only be called if <code class="docutils literal notranslate"><span class="pre">PyStatus_Exception(status)</span></code> is non-zero.</p>
</dd></dl>

</dd></dl>

<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Internally, Python uses macros which set <code class="docutils literal notranslate"><span class="pre">PyStatus.func</span></code>,
whereas functions to create a status set <code class="docutils literal notranslate"><span class="pre">func</span></code> to <code class="docutils literal notranslate"><span class="pre">NULL</span></code>.</p>
</div>
<p>Example:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">PyStatus</span> <span class="nf">alloc</span><span class="p">(</span><span class="kt">void</span> <span class="o">**</span><span class="n">ptr</span><span class="p">,</span> <span class="kt">size_t</span> <span class="n">size</span><span class="p">)</span>
<span class="p">{</span>
    <span class="o">*</span><span class="n">ptr</span> <span class="o">=</span> <span class="n">PyMem_RawMalloc</span><span class="p">(</span><span class="n">size</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="o">*</span><span class="n">ptr</span> <span class="o">==</span> <span class="nb">NULL</span><span class="p">)</span> <span class="p">{</span>
        <span class="k">return</span> <span class="n">PyStatus_NoMemory</span><span class="p">();</span>
    <span class="p">}</span>
    <span class="k">return</span> <span class="n">PyStatus_Ok</span><span class="p">();</span>
<span class="p">}</span>

<span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span>
<span class="p">{</span>
    <span class="kt">void</span> <span class="o">*</span><span class="n">ptr</span><span class="p">;</span>
    <span class="n">PyStatus</span> <span class="n">status</span> <span class="o">=</span> <span class="n">alloc</span><span class="p">(</span><span class="o">&amp;</span><span class="n">ptr</span><span class="p">,</span> <span class="mi">16</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">PyStatus_Exception</span><span class="p">(</span><span class="n">status</span><span class="p">))</span> <span class="p">{</span>
        <span class="n">Py_ExitStatusException</span><span class="p">(</span><span class="n">status</span><span class="p">);</span>
    <span class="p">}</span>
    <span class="n">PyMem_Free</span><span class="p">(</span><span class="n">ptr</span><span class="p">);</span>
    <span class="k">return</span> <span class="mi">0</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="pypreconfig">
<h2>PyPreConfig<a class="headerlink" href="#pypreconfig" title="Permalink to this headline">¶</a></h2>
<dl class="type">
<dt id="c.PyPreConfig">
<code class="sig-name descname">PyPreConfig</code><a class="headerlink" href="#c.PyPreConfig" title="Permalink to this definition">¶</a></dt>
<dd><p>Structure used to preinitialize Python:</p>
<ul class="simple">
<li><p>Set the Python memory allocator</p></li>
<li><p>Configure the LC_CTYPE locale</p></li>
<li><p>Set the UTF-8 mode</p></li>
</ul>
<p>Function to initialize a preconfiguration:</p>
<dl class="function">
<dt id="c.PyPreConfig_InitPythonConfig">
void <code class="sig-name descname">PyPreConfig_InitPythonConfig</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyPreConfig" title="PyPreConfig">PyPreConfig</a><em> *preconfig</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyPreConfig_InitPythonConfig" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize the preconfiguration with <a class="reference internal" href="#init-python-config"><span class="std std-ref">Python Configuration</span></a>.</p>
</dd></dl>

<dl class="function">
<dt id="c.PyPreConfig_InitIsolatedConfig">
void <code class="sig-name descname">PyPreConfig_InitIsolatedConfig</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyPreConfig" title="PyPreConfig">PyPreConfig</a><em> *preconfig</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyPreConfig_InitIsolatedConfig" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize the preconfiguration with <a class="reference internal" href="#init-isolated-conf"><span class="std std-ref">Isolated Configuration</span></a>.</p>
</dd></dl>

<p>Structure fields:</p>
<dl class="member">
<dt id="c.PyPreConfig.allocator">
int <code class="sig-name descname">allocator</code><a class="headerlink" href="#c.PyPreConfig.allocator" title="Permalink to this definition">¶</a></dt>
<dd><p>Name of the memory allocator:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">PYMEM_ALLOCATOR_NOT_SET</span></code> (<code class="docutils literal notranslate"><span class="pre">0</span></code>): don’t change memory allocators
(use defaults)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">PYMEM_ALLOCATOR_DEFAULT</span></code> (<code class="docutils literal notranslate"><span class="pre">1</span></code>): default memory allocators</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">PYMEM_ALLOCATOR_DEBUG</span></code> (<code class="docutils literal notranslate"><span class="pre">2</span></code>): default memory allocators with
debug hooks</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">PYMEM_ALLOCATOR_MALLOC</span></code> (<code class="docutils literal notranslate"><span class="pre">3</span></code>): force usage of <code class="docutils literal notranslate"><span class="pre">malloc()</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">PYMEM_ALLOCATOR_MALLOC_DEBUG</span></code> (<code class="docutils literal notranslate"><span class="pre">4</span></code>): force usage of
<code class="docutils literal notranslate"><span class="pre">malloc()</span></code> with debug hooks</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">PYMEM_ALLOCATOR_PYMALLOC</span></code> (<code class="docutils literal notranslate"><span class="pre">5</span></code>): <a class="reference internal" href="memory.html#pymalloc"><span class="std std-ref">Python pymalloc memory
allocator</span></a></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">PYMEM_ALLOCATOR_PYMALLOC_DEBUG</span></code> (<code class="docutils literal notranslate"><span class="pre">6</span></code>): <a class="reference internal" href="memory.html#pymalloc"><span class="std std-ref">Python pymalloc
memory allocator</span></a> with debug hooks</p></li>
</ul>
<p><code class="docutils literal notranslate"><span class="pre">PYMEM_ALLOCATOR_PYMALLOC</span></code> and <code class="docutils literal notranslate"><span class="pre">PYMEM_ALLOCATOR_PYMALLOC_DEBUG</span></code>
are not supported if Python is configured using <code class="docutils literal notranslate"><span class="pre">--without-pymalloc</span></code></p>
<p>See <a class="reference internal" href="memory.html#memory"><span class="std std-ref">Memory Management</span></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyPreConfig.configure_locale">
int <code class="sig-name descname">configure_locale</code><a class="headerlink" href="#c.PyPreConfig.configure_locale" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the LC_CTYPE locale to the user preferred locale? If equals to 0, set
<code class="xref c c-member docutils literal notranslate"><span class="pre">coerce_c_locale</span></code> and <code class="xref c c-member docutils literal notranslate"><span class="pre">coerce_c_locale_warn</span></code> to 0.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyPreConfig.coerce_c_locale">
int <code class="sig-name descname">coerce_c_locale</code><a class="headerlink" href="#c.PyPreConfig.coerce_c_locale" title="Permalink to this definition">¶</a></dt>
<dd><p>If equals to 2, coerce the C locale; if equals to 1, read the LC_CTYPE
locale to decide if it should be coerced.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyPreConfig.coerce_c_locale_warn">
int <code class="sig-name descname">coerce_c_locale_warn</code><a class="headerlink" href="#c.PyPreConfig.coerce_c_locale_warn" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, emit a warning if the C locale is coerced.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyPreConfig.dev_mode">
int <code class="sig-name descname">dev_mode</code><a class="headerlink" href="#c.PyPreConfig.dev_mode" title="Permalink to this definition">¶</a></dt>
<dd><p>See <a class="reference internal" href="#c.PyConfig.dev_mode" title="PyConfig.dev_mode"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.dev_mode</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyPreConfig.isolated">
int <code class="sig-name descname">isolated</code><a class="headerlink" href="#c.PyPreConfig.isolated" title="Permalink to this definition">¶</a></dt>
<dd><p>See <a class="reference internal" href="#c.PyConfig.isolated" title="PyConfig.isolated"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.isolated</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyPreConfig.legacy_windows_fs_encoding">
int <code class="sig-name descname">legacy_windows_fs_encoding</code><span class="sig-paren">(</span>Windows<em> only</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyPreConfig.legacy_windows_fs_encoding" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, disable UTF-8 Mode, set the Python filesystem encoding to
<code class="docutils literal notranslate"><span class="pre">mbcs</span></code>, set the filesystem error handler to <code class="docutils literal notranslate"><span class="pre">replace</span></code>.</p>
<p>Only available on Windows. <code class="docutils literal notranslate"><span class="pre">#ifdef</span> <span class="pre">MS_WINDOWS</span></code> macro can be used for
Windows specific code.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyPreConfig.parse_argv">
int <code class="sig-name descname">parse_argv</code><a class="headerlink" href="#c.PyPreConfig.parse_argv" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, <a class="reference internal" href="#c.Py_PreInitializeFromArgs" title="Py_PreInitializeFromArgs"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_PreInitializeFromArgs()</span></code></a> and
<a class="reference internal" href="#c.Py_PreInitializeFromBytesArgs" title="Py_PreInitializeFromBytesArgs"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_PreInitializeFromBytesArgs()</span></code></a> parse their <code class="docutils literal notranslate"><span class="pre">argv</span></code> argument the
same way the regular Python parses command line arguments: see
<a class="reference internal" href="../using/cmdline.html#using-on-cmdline"><span class="std std-ref">Command Line Arguments</span></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyPreConfig.use_environment">
int <code class="sig-name descname">use_environment</code><a class="headerlink" href="#c.PyPreConfig.use_environment" title="Permalink to this definition">¶</a></dt>
<dd><p>See <a class="reference internal" href="#c.PyConfig.use_environment" title="PyConfig.use_environment"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.use_environment</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyPreConfig.utf8_mode">
int <code class="sig-name descname">utf8_mode</code><a class="headerlink" href="#c.PyPreConfig.utf8_mode" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, enable the UTF-8 mode.</p>
</dd></dl>

</dd></dl>

</div>
<div class="section" id="preinitialization-with-pypreconfig">
<h2>Preinitialization with PyPreConfig<a class="headerlink" href="#preinitialization-with-pypreconfig" title="Permalink to this headline">¶</a></h2>
<p>Functions to preinitialize Python:</p>
<dl class="function">
<dt id="c.Py_PreInitialize">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">Py_PreInitialize</code><span class="sig-paren">(</span>const <a class="reference internal" href="#c.PyPreConfig" title="PyPreConfig">PyPreConfig</a><em> *preconfig</em><span class="sig-paren">)</span><a class="headerlink" href="#c.Py_PreInitialize" title="Permalink to this definition">¶</a></dt>
<dd><p>Preinitialize Python from <em>preconfig</em> preconfiguration.</p>
</dd></dl>

<dl class="function">
<dt id="c.Py_PreInitializeFromBytesArgs">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">Py_PreInitializeFromBytesArgs</code><span class="sig-paren">(</span>const <a class="reference internal" href="#c.PyPreConfig" title="PyPreConfig">PyPreConfig</a><em> *preconfig</em>, int<em> argc</em>, char * const<em> *argv</em><span class="sig-paren">)</span><a class="headerlink" href="#c.Py_PreInitializeFromBytesArgs" title="Permalink to this definition">¶</a></dt>
<dd><p>Preinitialize Python from <em>preconfig</em> preconfiguration and command line
arguments (bytes strings).</p>
</dd></dl>

<dl class="function">
<dt id="c.Py_PreInitializeFromArgs">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">Py_PreInitializeFromArgs</code><span class="sig-paren">(</span>const <a class="reference internal" href="#c.PyPreConfig" title="PyPreConfig">PyPreConfig</a><em> *preconfig</em>, int<em> argc</em>, wchar_t * const *<em> argv</em><span class="sig-paren">)</span><a class="headerlink" href="#c.Py_PreInitializeFromArgs" title="Permalink to this definition">¶</a></dt>
<dd><p>Preinitialize Python from <em>preconfig</em> preconfiguration and command line
arguments (wide strings).</p>
</dd></dl>

<p>The caller is responsible to handle exceptions (error or exit) using
<a class="reference internal" href="#c.PyStatus_Exception" title="PyStatus_Exception"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyStatus_Exception()</span></code></a> and <a class="reference internal" href="#c.Py_ExitStatusException" title="Py_ExitStatusException"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_ExitStatusException()</span></code></a>.</p>
<p>For <a class="reference internal" href="#init-python-config"><span class="std std-ref">Python Configuration</span></a>
(<a class="reference internal" href="#c.PyPreConfig_InitPythonConfig" title="PyPreConfig_InitPythonConfig"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyPreConfig_InitPythonConfig()</span></code></a>), if Python is initialized with
command line arguments, the command line arguments must also be passed to
preinitialize Python, since they have an effect on the pre-configuration
like encodings. For example, the <a class="reference internal" href="../using/cmdline.html#id5"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span> <span class="pre">utf8</span></code></a> command line option
enables the UTF-8 Mode.</p>
<p><code class="docutils literal notranslate"><span class="pre">PyMem_SetAllocator()</span></code> can be called after <a class="reference internal" href="#c.Py_PreInitialize" title="Py_PreInitialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_PreInitialize()</span></code></a> and
before <a class="reference internal" href="#c.Py_InitializeFromConfig" title="Py_InitializeFromConfig"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_InitializeFromConfig()</span></code></a> to install a custom memory allocator.
It can be called before <a class="reference internal" href="#c.Py_PreInitialize" title="Py_PreInitialize"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_PreInitialize()</span></code></a> if
<a class="reference internal" href="#c.PyPreConfig.allocator" title="PyPreConfig.allocator"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyPreConfig.allocator</span></code></a> is set to <code class="docutils literal notranslate"><span class="pre">PYMEM_ALLOCATOR_NOT_SET</span></code>.</p>
<p>Python memory allocation functions like <a class="reference internal" href="memory.html#c.PyMem_RawMalloc" title="PyMem_RawMalloc"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyMem_RawMalloc()</span></code></a> must not be
used before Python preinitialization, whereas calling directly <code class="docutils literal notranslate"><span class="pre">malloc()</span></code> and
<code class="docutils literal notranslate"><span class="pre">free()</span></code> is always safe. <a class="reference internal" href="sys.html#c.Py_DecodeLocale" title="Py_DecodeLocale"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_DecodeLocale()</span></code></a> must not be called before
the preinitialization.</p>
<p>Example using the preinitialization to enable the UTF-8 Mode:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">PyStatus</span> <span class="n">status</span><span class="p">;</span>
<span class="n">PyPreConfig</span> <span class="n">preconfig</span><span class="p">;</span>
<span class="n">PyPreConfig_InitPythonConfig</span><span class="p">(</span><span class="o">&amp;</span><span class="n">preconfig</span><span class="p">);</span>

<span class="n">preconfig</span><span class="p">.</span><span class="n">utf8_mode</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>

<span class="n">status</span> <span class="o">=</span> <span class="n">Py_PreInitialize</span><span class="p">(</span><span class="o">&amp;</span><span class="n">preconfig</span><span class="p">);</span>
<span class="k">if</span> <span class="p">(</span><span class="n">PyStatus_Exception</span><span class="p">(</span><span class="n">status</span><span class="p">))</span> <span class="p">{</span>
    <span class="n">Py_ExitStatusException</span><span class="p">(</span><span class="n">status</span><span class="p">);</span>
<span class="p">}</span>

<span class="cm">/* at this point, Python will speak UTF-8 */</span>

<span class="n">Py_Initialize</span><span class="p">();</span>
<span class="cm">/* ... use Python API here ... */</span>
<span class="n">Py_Finalize</span><span class="p">();</span>
</pre></div>
</div>
</div>
<div class="section" id="pyconfig">
<h2>PyConfig<a class="headerlink" href="#pyconfig" title="Permalink to this headline">¶</a></h2>
<dl class="type">
<dt id="c.PyConfig">
<code class="sig-name descname">PyConfig</code><a class="headerlink" href="#c.PyConfig" title="Permalink to this definition">¶</a></dt>
<dd><p>Structure containing most parameters to configure Python.</p>
<p>Structure methods:</p>
<dl class="function">
<dt id="c.PyConfig_InitPythonConfig">
void <code class="sig-name descname">PyConfig_InitPythonConfig</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyConfig" title="PyConfig">PyConfig</a><em> *config</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyConfig_InitPythonConfig" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize configuration with <a class="reference internal" href="#init-python-config"><span class="std std-ref">Python Configuration</span></a>.</p>
</dd></dl>

<dl class="function">
<dt id="c.PyConfig_InitIsolatedConfig">
void <code class="sig-name descname">PyConfig_InitIsolatedConfig</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyConfig" title="PyConfig">PyConfig</a><em> *config</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyConfig_InitIsolatedConfig" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize configuration with <a class="reference internal" href="#init-isolated-conf"><span class="std std-ref">Isolated Configuration</span></a>.</p>
</dd></dl>

<dl class="function">
<dt id="c.PyConfig_SetString">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">PyConfig_SetString</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyConfig" title="PyConfig">PyConfig</a><em> *config</em>, wchar_t * const<em> *config_str</em>, const wchar_t<em> *str</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyConfig_SetString" title="Permalink to this definition">¶</a></dt>
<dd><p>Copy the wide character string <em>str</em> into <code class="docutils literal notranslate"><span class="pre">*config_str</span></code>.</p>
<p>Preinitialize Python if needed.</p>
</dd></dl>

<dl class="function">
<dt id="c.PyConfig_SetBytesString">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">PyConfig_SetBytesString</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyConfig" title="PyConfig">PyConfig</a><em> *config</em>, wchar_t * const<em> *config_str</em>, const char<em> *str</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyConfig_SetBytesString" title="Permalink to this definition">¶</a></dt>
<dd><p>Decode <em>str</em> using <code class="docutils literal notranslate"><span class="pre">Py_DecodeLocale()</span></code> and set the result into <code class="docutils literal notranslate"><span class="pre">*config_str</span></code>.</p>
<p>Preinitialize Python if needed.</p>
</dd></dl>

<dl class="function">
<dt id="c.PyConfig_SetArgv">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">PyConfig_SetArgv</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyConfig" title="PyConfig">PyConfig</a><em> *config</em>, int<em> argc</em>, wchar_t * const<em> *argv</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyConfig_SetArgv" title="Permalink to this definition">¶</a></dt>
<dd><p>Set command line arguments from wide character strings.</p>
<p>Preinitialize Python if needed.</p>
</dd></dl>

<dl class="function">
<dt id="c.PyConfig_SetBytesArgv">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">PyConfig_SetBytesArgv</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyConfig" title="PyConfig">PyConfig</a><em> *config</em>, int<em> argc</em>, char * const<em> *argv</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyConfig_SetBytesArgv" title="Permalink to this definition">¶</a></dt>
<dd><p>Set command line arguments: decode bytes using <a class="reference internal" href="sys.html#c.Py_DecodeLocale" title="Py_DecodeLocale"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_DecodeLocale()</span></code></a>.</p>
<p>Preinitialize Python if needed.</p>
</dd></dl>

<dl class="function">
<dt id="c.PyConfig_SetWideStringList">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">PyConfig_SetWideStringList</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyConfig" title="PyConfig">PyConfig</a><em> *config</em>, <a class="reference internal" href="#c.PyWideStringList" title="PyWideStringList">PyWideStringList</a><em> *list</em>, Py_ssize_t<em> length</em>, wchar_t<em> **items</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyConfig_SetWideStringList" title="Permalink to this definition">¶</a></dt>
<dd><p>Set the list of wide strings <em>list</em> to <em>length</em> and <em>items</em>.</p>
<p>Preinitialize Python if needed.</p>
</dd></dl>

<dl class="function">
<dt id="c.PyConfig_Read">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">PyConfig_Read</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyConfig" title="PyConfig">PyConfig</a><em> *config</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyConfig_Read" title="Permalink to this definition">¶</a></dt>
<dd><p>Read all Python configuration.</p>
<p>Fields which are already initialized are left unchanged.</p>
<p>Preinitialize Python if needed.</p>
</dd></dl>

<dl class="function">
<dt id="c.PyConfig_Clear">
void <code class="sig-name descname">PyConfig_Clear</code><span class="sig-paren">(</span><a class="reference internal" href="#c.PyConfig" title="PyConfig">PyConfig</a><em> *config</em><span class="sig-paren">)</span><a class="headerlink" href="#c.PyConfig_Clear" title="Permalink to this definition">¶</a></dt>
<dd><p>Release configuration memory.</p>
</dd></dl>

<p>Most <code class="docutils literal notranslate"><span class="pre">PyConfig</span></code> methods preinitialize Python if needed. In that case, the
Python preinitialization configuration in based on the <a class="reference internal" href="#c.PyConfig" title="PyConfig"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyConfig</span></code></a>.
If configuration fields which are in common with <a class="reference internal" href="#c.PyPreConfig" title="PyPreConfig"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyPreConfig</span></code></a> are
tuned, they must be set before calling a <a class="reference internal" href="#c.PyConfig" title="PyConfig"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyConfig</span></code></a> method:</p>
<ul class="simple">
<li><p><a class="reference internal" href="#c.PyConfig.dev_mode" title="PyConfig.dev_mode"><code class="xref c c-member docutils literal notranslate"><span class="pre">dev_mode</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig.isolated" title="PyConfig.isolated"><code class="xref c c-member docutils literal notranslate"><span class="pre">isolated</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig.parse_argv" title="PyConfig.parse_argv"><code class="xref c c-member docutils literal notranslate"><span class="pre">parse_argv</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig.use_environment" title="PyConfig.use_environment"><code class="xref c c-member docutils literal notranslate"><span class="pre">use_environment</span></code></a></p></li>
</ul>
<p>Moreover, if <a class="reference internal" href="#c.PyConfig_SetArgv" title="PyConfig_SetArgv"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_SetArgv()</span></code></a> or <a class="reference internal" href="#c.PyConfig_SetBytesArgv" title="PyConfig_SetBytesArgv"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_SetBytesArgv()</span></code></a>
is used, this method must be called first, before other methods, since the
preinitialization configuration depends on command line arguments (if
<code class="xref c c-member docutils literal notranslate"><span class="pre">parse_argv</span></code> is non-zero).</p>
<p>The caller of these methods is responsible to handle exceptions (error or
exit) using <code class="docutils literal notranslate"><span class="pre">PyStatus_Exception()</span></code> and <code class="docutils literal notranslate"><span class="pre">Py_ExitStatusException()</span></code>.</p>
<p>Structure fields:</p>
<dl class="member">
<dt id="c.PyConfig.argv">
<a class="reference internal" href="#c.PyWideStringList" title="PyWideStringList">PyWideStringList</a> <code class="sig-name descname">argv</code><a class="headerlink" href="#c.PyConfig.argv" title="Permalink to this definition">¶</a></dt>
<dd><p>Command line arguments, <a class="reference internal" href="../library/sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.argv</span></code></a>. See
<a class="reference internal" href="#c.PyConfig.parse_argv" title="PyConfig.parse_argv"><code class="xref c c-member docutils literal notranslate"><span class="pre">parse_argv</span></code></a> to parse <a class="reference internal" href="#c.PyConfig.argv" title="PyConfig.argv"><code class="xref c c-member docutils literal notranslate"><span class="pre">argv</span></code></a> the
same way the regular Python parses Python command line arguments. If
<a class="reference internal" href="#c.PyConfig.argv" title="PyConfig.argv"><code class="xref c c-member docutils literal notranslate"><span class="pre">argv</span></code></a> is empty, an empty string is added to ensure
that <a class="reference internal" href="../library/sys.html#sys.argv" title="sys.argv"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.argv</span></code></a> always exists and is never empty.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.base_exec_prefix">
wchar_t* <code class="sig-name descname">base_exec_prefix</code><a class="headerlink" href="#c.PyConfig.base_exec_prefix" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference internal" href="../library/sys.html#sys.base_exec_prefix" title="sys.base_exec_prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.base_exec_prefix</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.base_executable">
wchar_t* <code class="sig-name descname">base_executable</code><a class="headerlink" href="#c.PyConfig.base_executable" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="xref py py-data docutils literal notranslate"><span class="pre">sys._base_executable</span></code>: <code class="docutils literal notranslate"><span class="pre">__PYVENV_LAUNCHER__</span></code> environment
variable value, or copy of <a class="reference internal" href="#c.PyConfig.executable" title="PyConfig.executable"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.executable</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.base_prefix">
wchar_t* <code class="sig-name descname">base_prefix</code><a class="headerlink" href="#c.PyConfig.base_prefix" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference internal" href="../library/sys.html#sys.base_prefix" title="sys.base_prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.base_prefix</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.buffered_stdio">
int <code class="sig-name descname">buffered_stdio</code><a class="headerlink" href="#c.PyConfig.buffered_stdio" title="Permalink to this definition">¶</a></dt>
<dd><p>If equals to 0, enable unbuffered mode, making the stdout and stderr
streams unbuffered.</p>
<p>stdin is always opened in buffered mode.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.bytes_warning">
int <code class="sig-name descname">bytes_warning</code><a class="headerlink" href="#c.PyConfig.bytes_warning" title="Permalink to this definition">¶</a></dt>
<dd><p>If equals to 1, issue a warning when comparing <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> or
<a class="reference internal" href="../library/stdtypes.html#bytearray" title="bytearray"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytearray</span></code></a> with <a class="reference internal" href="../library/stdtypes.html#str" title="str"><code class="xref py py-class docutils literal notranslate"><span class="pre">str</span></code></a>, or comparing <a class="reference internal" href="../library/stdtypes.html#bytes" title="bytes"><code class="xref py py-class docutils literal notranslate"><span class="pre">bytes</span></code></a> with
<a class="reference internal" href="../library/functions.html#int" title="int"><code class="xref py py-class docutils literal notranslate"><span class="pre">int</span></code></a>. If equal or greater to 2, raise a <a class="reference internal" href="../library/exceptions.html#BytesWarning" title="BytesWarning"><code class="xref py py-exc docutils literal notranslate"><span class="pre">BytesWarning</span></code></a>
exception.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.check_hash_pycs_mode">
wchar_t* <code class="sig-name descname">check_hash_pycs_mode</code><a class="headerlink" href="#c.PyConfig.check_hash_pycs_mode" title="Permalink to this definition">¶</a></dt>
<dd><p>Control the validation behavior of hash-based <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files (see
<span class="target" id="index-1"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0552"><strong>PEP 552</strong></a>): <a class="reference internal" href="../using/cmdline.html#cmdoption-check-hash-based-pycs"><code class="xref std std-option docutils literal notranslate"><span class="pre">--check-hash-based-pycs</span></code></a> command line option value.</p>
<p>Valid values: <code class="docutils literal notranslate"><span class="pre">always</span></code>, <code class="docutils literal notranslate"><span class="pre">never</span></code> and <code class="docutils literal notranslate"><span class="pre">default</span></code>.</p>
<p>The default value is: <code class="docutils literal notranslate"><span class="pre">default</span></code>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.configure_c_stdio">
int <code class="sig-name descname">configure_c_stdio</code><a class="headerlink" href="#c.PyConfig.configure_c_stdio" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, configure C standard streams (<code class="docutils literal notranslate"><span class="pre">stdio</span></code>, <code class="docutils literal notranslate"><span class="pre">stdout</span></code>,
<code class="docutils literal notranslate"><span class="pre">stdout</span></code>). For example, set their mode to <code class="docutils literal notranslate"><span class="pre">O_BINARY</span></code> on Windows.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.dev_mode">
int <code class="sig-name descname">dev_mode</code><a class="headerlink" href="#c.PyConfig.dev_mode" title="Permalink to this definition">¶</a></dt>
<dd><p>Development mode: see <a class="reference internal" href="../using/cmdline.html#id5"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span> <span class="pre">dev</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.dump_refs">
int <code class="sig-name descname">dump_refs</code><a class="headerlink" href="#c.PyConfig.dump_refs" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, dump all objects which are still alive at exit.</p>
<p>Require a debug build of Python (<code class="docutils literal notranslate"><span class="pre">Py_REF_DEBUG</span></code> macro must be defined).</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.exec_prefix">
wchar_t* <code class="sig-name descname">exec_prefix</code><a class="headerlink" href="#c.PyConfig.exec_prefix" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference internal" href="../library/sys.html#sys.exec_prefix" title="sys.exec_prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.exec_prefix</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.executable">
wchar_t* <code class="sig-name descname">executable</code><a class="headerlink" href="#c.PyConfig.executable" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference internal" href="../library/sys.html#sys.executable" title="sys.executable"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.executable</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.faulthandler">
int <code class="sig-name descname">faulthandler</code><a class="headerlink" href="#c.PyConfig.faulthandler" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, call <a class="reference internal" href="../library/faulthandler.html#faulthandler.enable" title="faulthandler.enable"><code class="xref py py-func docutils literal notranslate"><span class="pre">faulthandler.enable()</span></code></a> at startup.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.filesystem_encoding">
wchar_t* <code class="sig-name descname">filesystem_encoding</code><a class="headerlink" href="#c.PyConfig.filesystem_encoding" title="Permalink to this definition">¶</a></dt>
<dd><p>Filesystem encoding, <a class="reference internal" href="../library/sys.html#sys.getfilesystemencoding" title="sys.getfilesystemencoding"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.getfilesystemencoding()</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.filesystem_errors">
wchar_t* <code class="sig-name descname">filesystem_errors</code><a class="headerlink" href="#c.PyConfig.filesystem_errors" title="Permalink to this definition">¶</a></dt>
<dd><p>Filesystem encoding errors, <a class="reference internal" href="../library/sys.html#sys.getfilesystemencodeerrors" title="sys.getfilesystemencodeerrors"><code class="xref py py-func docutils literal notranslate"><span class="pre">sys.getfilesystemencodeerrors()</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.hash_seed">
unsigned long <code class="sig-name descname">hash_seed</code><a class="headerlink" href="#c.PyConfig.hash_seed" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="member">
<dt id="c.PyConfig.use_hash_seed">
int <code class="sig-name descname">use_hash_seed</code><a class="headerlink" href="#c.PyConfig.use_hash_seed" title="Permalink to this definition">¶</a></dt>
<dd><p>Randomized hash function seed.</p>
<p>If <a class="reference internal" href="#c.PyConfig.use_hash_seed" title="PyConfig.use_hash_seed"><code class="xref c c-member docutils literal notranslate"><span class="pre">use_hash_seed</span></code></a> is zero, a seed is chosen randomly
at Pythonstartup, and <a class="reference internal" href="#c.PyConfig.hash_seed" title="PyConfig.hash_seed"><code class="xref c c-member docutils literal notranslate"><span class="pre">hash_seed</span></code></a> is ignored.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.home">
wchar_t* <code class="sig-name descname">home</code><a class="headerlink" href="#c.PyConfig.home" title="Permalink to this definition">¶</a></dt>
<dd><p>Python home directory.</p>
<p>Initialized from <span class="target" id="index-2"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONHOME"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONHOME</span></code></a> environment variable value by
default.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.import_time">
int <code class="sig-name descname">import_time</code><a class="headerlink" href="#c.PyConfig.import_time" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, profile import time.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.inspect">
int <code class="sig-name descname">inspect</code><a class="headerlink" href="#c.PyConfig.inspect" title="Permalink to this definition">¶</a></dt>
<dd><p>Enter interactive mode after executing a script or a command.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.install_signal_handlers">
int <code class="sig-name descname">install_signal_handlers</code><a class="headerlink" href="#c.PyConfig.install_signal_handlers" title="Permalink to this definition">¶</a></dt>
<dd><p>Install signal handlers?</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.interactive">
int <code class="sig-name descname">interactive</code><a class="headerlink" href="#c.PyConfig.interactive" title="Permalink to this definition">¶</a></dt>
<dd><p>Interactive mode.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.isolated">
int <code class="sig-name descname">isolated</code><a class="headerlink" href="#c.PyConfig.isolated" title="Permalink to this definition">¶</a></dt>
<dd><p>If greater than 0, enable isolated mode:</p>
<ul class="simple">
<li><p><a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> contains neither the script’s directory (computed from
<code class="docutils literal notranslate"><span class="pre">argv[0]</span></code> or the current directory) nor the user’s site-packages
directory.</p></li>
<li><p>Python REPL doesn’t import <a class="reference internal" href="../library/readline.html#module-readline" title="readline: GNU readline support for Python. (Unix)"><code class="xref py py-mod docutils literal notranslate"><span class="pre">readline</span></code></a> nor enable default readline
configuration on interactive prompts.</p></li>
<li><p>Set <a class="reference internal" href="#c.PyConfig.use_environment" title="PyConfig.use_environment"><code class="xref c c-member docutils literal notranslate"><span class="pre">use_environment</span></code></a> and
<a class="reference internal" href="#c.PyConfig.user_site_directory" title="PyConfig.user_site_directory"><code class="xref c c-member docutils literal notranslate"><span class="pre">user_site_directory</span></code></a> to 0.</p></li>
</ul>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.legacy_windows_stdio">
int <code class="sig-name descname">legacy_windows_stdio</code><a class="headerlink" href="#c.PyConfig.legacy_windows_stdio" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, use <a class="reference internal" href="../library/io.html#io.FileIO" title="io.FileIO"><code class="xref py py-class docutils literal notranslate"><span class="pre">io.FileIO</span></code></a> instead of
<code class="xref py py-class docutils literal notranslate"><span class="pre">io.WindowsConsoleIO</span></code> for <a class="reference internal" href="../library/sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdin</span></code></a>, <a class="reference internal" href="../library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdout</span></code></a>
and <a class="reference internal" href="../library/sys.html#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stderr</span></code></a>.</p>
<p>Only available on Windows. <code class="docutils literal notranslate"><span class="pre">#ifdef</span> <span class="pre">MS_WINDOWS</span></code> macro can be used for
Windows specific code.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.malloc_stats">
int <code class="sig-name descname">malloc_stats</code><a class="headerlink" href="#c.PyConfig.malloc_stats" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, dump statistics on <a class="reference internal" href="memory.html#pymalloc"><span class="std std-ref">Python pymalloc memory allocator</span></a> at exit.</p>
<p>The option is ignored if Python is built using <code class="docutils literal notranslate"><span class="pre">--without-pymalloc</span></code>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.pythonpath_env">
wchar_t* <code class="sig-name descname">pythonpath_env</code><a class="headerlink" href="#c.PyConfig.pythonpath_env" title="Permalink to this definition">¶</a></dt>
<dd><p>Module search paths as a string separated by <code class="docutils literal notranslate"><span class="pre">DELIM</span></code>
(<code class="xref py py-data docutils literal notranslate"><span class="pre">os.path.pathsep</span></code>).</p>
<p>Initialized from <span class="target" id="index-3"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONPATH"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONPATH</span></code></a> environment variable value by
default.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.module_search_paths">
<a class="reference internal" href="#c.PyWideStringList" title="PyWideStringList">PyWideStringList</a> <code class="sig-name descname">module_search_paths</code><a class="headerlink" href="#c.PyConfig.module_search_paths" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="member">
<dt id="c.PyConfig.module_search_paths_set">
int <code class="sig-name descname">module_search_paths_set</code><a class="headerlink" href="#c.PyConfig.module_search_paths_set" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>. If <a class="reference internal" href="#c.PyConfig.module_search_paths_set" title="PyConfig.module_search_paths_set"><code class="xref c c-member docutils literal notranslate"><span class="pre">module_search_paths_set</span></code></a> is
equal to 0, the <a class="reference internal" href="#c.PyConfig.module_search_paths" title="PyConfig.module_search_paths"><code class="xref c c-member docutils literal notranslate"><span class="pre">module_search_paths</span></code></a> is overridden
by the function calculating the <a class="reference internal" href="#init-path-config"><span class="std std-ref">Path Configuration</span></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.optimization_level">
int <code class="sig-name descname">optimization_level</code><a class="headerlink" href="#c.PyConfig.optimization_level" title="Permalink to this definition">¶</a></dt>
<dd><p>Compilation optimization level:</p>
<ul class="simple">
<li><p>0: Peephole optimizer (and <code class="docutils literal notranslate"><span class="pre">__debug__</span></code> is set to <code class="docutils literal notranslate"><span class="pre">True</span></code>)</p></li>
<li><p>1: Remove assertions, set <code class="docutils literal notranslate"><span class="pre">__debug__</span></code> to <code class="docutils literal notranslate"><span class="pre">False</span></code></p></li>
<li><p>2: Strip docstrings</p></li>
</ul>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.parse_argv">
int <code class="sig-name descname">parse_argv</code><a class="headerlink" href="#c.PyConfig.parse_argv" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, parse <a class="reference internal" href="#c.PyConfig.argv" title="PyConfig.argv"><code class="xref c c-member docutils literal notranslate"><span class="pre">argv</span></code></a> the same way the regular
Python command line arguments, and strip Python arguments from
<a class="reference internal" href="#c.PyConfig.argv" title="PyConfig.argv"><code class="xref c c-member docutils literal notranslate"><span class="pre">argv</span></code></a>: see <a class="reference internal" href="../using/cmdline.html#using-on-cmdline"><span class="std std-ref">Command Line Arguments</span></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.parser_debug">
int <code class="sig-name descname">parser_debug</code><a class="headerlink" href="#c.PyConfig.parser_debug" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, turn on parser debugging output (for expert only, depending
on compilation options).</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.pathconfig_warnings">
int <code class="sig-name descname">pathconfig_warnings</code><a class="headerlink" href="#c.PyConfig.pathconfig_warnings" title="Permalink to this definition">¶</a></dt>
<dd><p>If equal to 0, suppress warnings when calculating the <a class="reference internal" href="#init-path-config"><span class="std std-ref">Path
Configuration</span></a> (Unix only, Windows does not log any
warning). Otherwise, warnings are written into <code class="docutils literal notranslate"><span class="pre">stderr</span></code>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.prefix">
wchar_t* <code class="sig-name descname">prefix</code><a class="headerlink" href="#c.PyConfig.prefix" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference internal" href="../library/sys.html#sys.prefix" title="sys.prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.prefix</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.program_name">
wchar_t* <code class="sig-name descname">program_name</code><a class="headerlink" href="#c.PyConfig.program_name" title="Permalink to this definition">¶</a></dt>
<dd><p>Program name. Used to initialize <a class="reference internal" href="#c.PyConfig.executable" title="PyConfig.executable"><code class="xref c c-member docutils literal notranslate"><span class="pre">executable</span></code></a>, and in
early error messages.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.pycache_prefix">
wchar_t* <code class="sig-name descname">pycache_prefix</code><a class="headerlink" href="#c.PyConfig.pycache_prefix" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference internal" href="../library/sys.html#sys.pycache_prefix" title="sys.pycache_prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.pycache_prefix</span></code></a>: <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> cache prefix.</p>
<p>If <code class="docutils literal notranslate"><span class="pre">NULL</span></code>, <a class="reference internal" href="../library/sys.html#sys.pycache_prefix" title="sys.pycache_prefix"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.pycache_prefix</span></code></a> is set to <code class="docutils literal notranslate"><span class="pre">None</span></code>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.quiet">
int <code class="sig-name descname">quiet</code><a class="headerlink" href="#c.PyConfig.quiet" title="Permalink to this definition">¶</a></dt>
<dd><p>Quiet mode. For example, don’t display the copyright and version messages
in interactive mode.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.run_command">
wchar_t* <code class="sig-name descname">run_command</code><a class="headerlink" href="#c.PyConfig.run_command" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">python3</span> <span class="pre">-c</span> <span class="pre">COMMAND</span></code> argument. Used by <a class="reference internal" href="#c.Py_RunMain" title="Py_RunMain"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_RunMain()</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.run_filename">
wchar_t* <code class="sig-name descname">run_filename</code><a class="headerlink" href="#c.PyConfig.run_filename" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">python3</span> <span class="pre">FILENAME</span></code> argument. Used by <a class="reference internal" href="#c.Py_RunMain" title="Py_RunMain"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_RunMain()</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.run_module">
wchar_t* <code class="sig-name descname">run_module</code><a class="headerlink" href="#c.PyConfig.run_module" title="Permalink to this definition">¶</a></dt>
<dd><p><code class="docutils literal notranslate"><span class="pre">python3</span> <span class="pre">-m</span> <span class="pre">MODULE</span></code> argument. Used by <a class="reference internal" href="#c.Py_RunMain" title="Py_RunMain"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_RunMain()</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.show_alloc_count">
int <code class="sig-name descname">show_alloc_count</code><a class="headerlink" href="#c.PyConfig.show_alloc_count" title="Permalink to this definition">¶</a></dt>
<dd><p>Show allocation counts at exit?</p>
<p>Set to 1 by <a class="reference internal" href="../using/cmdline.html#id5"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span> <span class="pre">showalloccount</span></code></a> command line option.</p>
<p>Need a special Python build with <code class="docutils literal notranslate"><span class="pre">COUNT_ALLOCS</span></code> macro defined.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.show_ref_count">
int <code class="sig-name descname">show_ref_count</code><a class="headerlink" href="#c.PyConfig.show_ref_count" title="Permalink to this definition">¶</a></dt>
<dd><p>Show total reference count at exit?</p>
<p>Set to 1 by <a class="reference internal" href="../using/cmdline.html#id5"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span> <span class="pre">showrefcount</span></code></a> command line option.</p>
<p>Need a debug build of Python (<code class="docutils literal notranslate"><span class="pre">Py_REF_DEBUG</span></code> macro must be defined).</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.site_import">
int <code class="sig-name descname">site_import</code><a class="headerlink" href="#c.PyConfig.site_import" title="Permalink to this definition">¶</a></dt>
<dd><p>Import the <a class="reference internal" href="../library/site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code></a> module at startup?</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.skip_source_first_line">
int <code class="sig-name descname">skip_source_first_line</code><a class="headerlink" href="#c.PyConfig.skip_source_first_line" title="Permalink to this definition">¶</a></dt>
<dd><p>Skip the first line of the source?</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.stdio_encoding">
wchar_t* <code class="sig-name descname">stdio_encoding</code><a class="headerlink" href="#c.PyConfig.stdio_encoding" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<dl class="member">
<dt id="c.PyConfig.stdio_errors">
wchar_t* <code class="sig-name descname">stdio_errors</code><a class="headerlink" href="#c.PyConfig.stdio_errors" title="Permalink to this definition">¶</a></dt>
<dd><p>Encoding and encoding errors of <a class="reference internal" href="../library/sys.html#sys.stdin" title="sys.stdin"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdin</span></code></a>, <a class="reference internal" href="../library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdout</span></code></a> and
<a class="reference internal" href="../library/sys.html#sys.stderr" title="sys.stderr"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stderr</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.tracemalloc">
int <code class="sig-name descname">tracemalloc</code><a class="headerlink" href="#c.PyConfig.tracemalloc" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, call <a class="reference internal" href="../library/tracemalloc.html#tracemalloc.start" title="tracemalloc.start"><code class="xref py py-func docutils literal notranslate"><span class="pre">tracemalloc.start()</span></code></a> at startup.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.use_environment">
int <code class="sig-name descname">use_environment</code><a class="headerlink" href="#c.PyConfig.use_environment" title="Permalink to this definition">¶</a></dt>
<dd><p>If greater than 0, use <a class="reference internal" href="../using/cmdline.html#using-on-envvars"><span class="std std-ref">environment variables</span></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.user_site_directory">
int <code class="sig-name descname">user_site_directory</code><a class="headerlink" href="#c.PyConfig.user_site_directory" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, add user site directory to <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.verbose">
int <code class="sig-name descname">verbose</code><a class="headerlink" href="#c.PyConfig.verbose" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, enable verbose mode.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.warnoptions">
<a class="reference internal" href="#c.PyWideStringList" title="PyWideStringList">PyWideStringList</a> <code class="sig-name descname">warnoptions</code><a class="headerlink" href="#c.PyConfig.warnoptions" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference internal" href="../library/sys.html#sys.warnoptions" title="sys.warnoptions"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.warnoptions</span></code></a>: options of the <a class="reference internal" href="../library/warnings.html#module-warnings" title="warnings: Issue warning messages and control their disposition."><code class="xref py py-mod docutils literal notranslate"><span class="pre">warnings</span></code></a> module to build
warnings filters: lowest to highest priority.</p>
<p>The <a class="reference internal" href="../library/warnings.html#module-warnings" title="warnings: Issue warning messages and control their disposition."><code class="xref py py-mod docutils literal notranslate"><span class="pre">warnings</span></code></a> module adds <a class="reference internal" href="../library/sys.html#sys.warnoptions" title="sys.warnoptions"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.warnoptions</span></code></a> in the reverse
order: the last <a class="reference internal" href="#c.PyConfig.warnoptions" title="PyConfig.warnoptions"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.warnoptions</span></code></a> item becomes the first
item of <code class="xref py py-data docutils literal notranslate"><span class="pre">warnings.filters</span></code> which is checked first (highest
priority).</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.write_bytecode">
int <code class="sig-name descname">write_bytecode</code><a class="headerlink" href="#c.PyConfig.write_bytecode" title="Permalink to this definition">¶</a></dt>
<dd><p>If non-zero, write <code class="docutils literal notranslate"><span class="pre">.pyc</span></code> files.</p>
<p><a class="reference internal" href="../library/sys.html#sys.dont_write_bytecode" title="sys.dont_write_bytecode"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.dont_write_bytecode</span></code></a> is initialized to the inverted value of
<a class="reference internal" href="#c.PyConfig.write_bytecode" title="PyConfig.write_bytecode"><code class="xref c c-member docutils literal notranslate"><span class="pre">write_bytecode</span></code></a>.</p>
</dd></dl>

<dl class="member">
<dt id="c.PyConfig.xoptions">
<a class="reference internal" href="#c.PyWideStringList" title="PyWideStringList">PyWideStringList</a> <code class="sig-name descname">xoptions</code><a class="headerlink" href="#c.PyConfig.xoptions" title="Permalink to this definition">¶</a></dt>
<dd><p><a class="reference internal" href="../library/sys.html#sys._xoptions" title="sys._xoptions"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys._xoptions</span></code></a>.</p>
</dd></dl>

</dd></dl>

<p>If <code class="docutils literal notranslate"><span class="pre">parse_argv</span></code> is non-zero, <code class="docutils literal notranslate"><span class="pre">argv</span></code> arguments are parsed the same
way the regular Python parses command line arguments, and Python
arguments are stripped from <code class="docutils literal notranslate"><span class="pre">argv</span></code>: see <a class="reference internal" href="../using/cmdline.html#using-on-cmdline"><span class="std std-ref">Command Line Arguments</span></a>.</p>
<p>The <code class="docutils literal notranslate"><span class="pre">xoptions</span></code> options are parsed to set other options: see <a class="reference internal" href="../using/cmdline.html#id5"><code class="xref std std-option docutils literal notranslate"><span class="pre">-X</span></code></a>
option.</p>
</div>
<div class="section" id="initialization-with-pyconfig">
<h2>Initialization with PyConfig<a class="headerlink" href="#initialization-with-pyconfig" title="Permalink to this headline">¶</a></h2>
<p>Function to initialize Python:</p>
<dl class="function">
<dt id="c.Py_InitializeFromConfig">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">Py_InitializeFromConfig</code><span class="sig-paren">(</span>const <a class="reference internal" href="#c.PyConfig" title="PyConfig">PyConfig</a><em> *config</em><span class="sig-paren">)</span><a class="headerlink" href="#c.Py_InitializeFromConfig" title="Permalink to this definition">¶</a></dt>
<dd><p>Initialize Python from <em>config</em> configuration.</p>
</dd></dl>

<p>The caller is responsible to handle exceptions (error or exit) using
<a class="reference internal" href="#c.PyStatus_Exception" title="PyStatus_Exception"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyStatus_Exception()</span></code></a> and <a class="reference internal" href="#c.Py_ExitStatusException" title="Py_ExitStatusException"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_ExitStatusException()</span></code></a>.</p>
<p>If <code class="docutils literal notranslate"><span class="pre">PyImport_FrozenModules</span></code>, <code class="docutils literal notranslate"><span class="pre">PyImport_AppendInittab()</span></code> or
<code class="docutils literal notranslate"><span class="pre">PyImport_ExtendInittab()</span></code> are used, they must be set or called after Python
preinitialization and before the Python initialization.</p>
<p>Example setting the program name:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">init_python</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span>
<span class="p">{</span>
    <span class="n">PyStatus</span> <span class="n">status</span><span class="p">;</span>

    <span class="n">PyConfig</span> <span class="n">config</span><span class="p">;</span>
    <span class="n">PyConfig_InitPythonConfig</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>

    <span class="cm">/* Set the program name. Implicitly preinitialize Python. */</span>
    <span class="n">status</span> <span class="o">=</span> <span class="n">PyConfig_SetString</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">config</span><span class="p">.</span><span class="n">program_name</span><span class="p">,</span>
                                <span class="sa">L</span><span class="s">&quot;/path/to/my_program&quot;</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">PyStatus_Exception</span><span class="p">(</span><span class="n">status</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">goto</span> <span class="n">fail</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="n">status</span> <span class="o">=</span> <span class="n">Py_InitializeFromConfig</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">PyStatus_Exception</span><span class="p">(</span><span class="n">status</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">goto</span> <span class="n">fail</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="n">PyConfig_Clear</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>
    <span class="k">return</span><span class="p">;</span>

<span class="nl">fail</span><span class="p">:</span>
    <span class="n">PyConfig_Clear</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>
    <span class="n">Py_ExitStatusException</span><span class="p">(</span><span class="n">status</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
<p>More complete example modifying the default configuration, read the
configuration, and then override some parameters:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="n">PyStatus</span> <span class="nf">init_python</span><span class="p">(</span><span class="k">const</span> <span class="kt">char</span> <span class="o">*</span><span class="n">program_name</span><span class="p">)</span>
<span class="p">{</span>
    <span class="n">PyStatus</span> <span class="n">status</span><span class="p">;</span>

    <span class="n">PyConfig</span> <span class="n">config</span><span class="p">;</span>
    <span class="n">PyConfig_InitPythonConfig</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>

    <span class="cm">/* Set the program name before reading the configuration</span>
<span class="cm">       (decode byte string from the locale encoding).</span>

<span class="cm">       Implicitly preinitialize Python. */</span>
    <span class="n">status</span> <span class="o">=</span> <span class="n">PyConfig_SetBytesString</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">config</span><span class="p">.</span><span class="n">program_name</span><span class="p">,</span>
                                  <span class="n">program_name</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">PyStatus_Exception</span><span class="p">(</span><span class="n">status</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">goto</span> <span class="n">done</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="cm">/* Read all configuration at once */</span>
    <span class="n">status</span> <span class="o">=</span> <span class="n">PyConfig_Read</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">PyStatus_Exception</span><span class="p">(</span><span class="n">status</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">goto</span> <span class="n">done</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="cm">/* Append our custom search path to sys.path */</span>
    <span class="n">status</span> <span class="o">=</span> <span class="n">PyWideStringList_Append</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">.</span><span class="n">module_search_paths</span><span class="p">,</span>
                                     <span class="sa">L</span><span class="s">&quot;/path/to/more/modules&quot;</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">PyStatus_Exception</span><span class="p">(</span><span class="n">status</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">goto</span> <span class="n">done</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="cm">/* Override executable computed by PyConfig_Read() */</span>
    <span class="n">status</span> <span class="o">=</span> <span class="n">PyConfig_SetString</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">,</span> <span class="o">&amp;</span><span class="n">config</span><span class="p">.</span><span class="n">executable</span><span class="p">,</span>
                                <span class="sa">L</span><span class="s">&quot;/path/to/my_executable&quot;</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">PyStatus_Exception</span><span class="p">(</span><span class="n">status</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">goto</span> <span class="n">done</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="n">status</span> <span class="o">=</span> <span class="n">Py_InitializeFromConfig</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>

<span class="nl">done</span><span class="p">:</span>
    <span class="n">PyConfig_Clear</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>
    <span class="k">return</span> <span class="n">status</span><span class="p">;</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="isolated-configuration">
<span id="init-isolated-conf"></span><h2>Isolated Configuration<a class="headerlink" href="#isolated-configuration" title="Permalink to this headline">¶</a></h2>
<p><a class="reference internal" href="#c.PyPreConfig_InitIsolatedConfig" title="PyPreConfig_InitIsolatedConfig"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyPreConfig_InitIsolatedConfig()</span></code></a> and
<a class="reference internal" href="#c.PyConfig_InitIsolatedConfig" title="PyConfig_InitIsolatedConfig"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_InitIsolatedConfig()</span></code></a> functions create a configuration to
isolate Python from the system. For example, to embed Python into an
application.</p>
<p>This configuration ignores global configuration variables, environments
variables, command line arguments (<a class="reference internal" href="#c.PyConfig.argv" title="PyConfig.argv"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.argv</span></code></a> is not parsed)
and user site directory. The C standard streams (ex: <code class="docutils literal notranslate"><span class="pre">stdout</span></code>) and the
LC_CTYPE locale are left unchanged. Signal handlers are not installed.</p>
<p>Configuration files are still used with this configuration. Set the
<a class="reference internal" href="#init-path-config"><span class="std std-ref">Path Configuration</span></a> (“output fields”) to ignore these
configuration files and avoid the function computing the default path
configuration.</p>
</div>
<div class="section" id="python-configuration">
<span id="init-python-config"></span><h2>Python Configuration<a class="headerlink" href="#python-configuration" title="Permalink to this headline">¶</a></h2>
<p><a class="reference internal" href="#c.PyPreConfig_InitPythonConfig" title="PyPreConfig_InitPythonConfig"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyPreConfig_InitPythonConfig()</span></code></a> and <a class="reference internal" href="#c.PyConfig_InitPythonConfig" title="PyConfig_InitPythonConfig"><code class="xref c c-func docutils literal notranslate"><span class="pre">PyConfig_InitPythonConfig()</span></code></a>
functions create a configuration to build a customized Python which behaves as
the regular Python.</p>
<p>Environments variables and command line arguments are used to configure
Python, whereas global configuration variables are ignored.</p>
<p>This function enables C locale coercion (<span class="target" id="index-4"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0538"><strong>PEP 538</strong></a>) and UTF-8 Mode
(<span class="target" id="index-5"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0540"><strong>PEP 540</strong></a>) depending on the LC_CTYPE locale, <span class="target" id="index-6"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONUTF8"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONUTF8</span></code></a> and
<span class="target" id="index-7"></span><a class="reference internal" href="../using/cmdline.html#envvar-PYTHONCOERCECLOCALE"><code class="xref std std-envvar docutils literal notranslate"><span class="pre">PYTHONCOERCECLOCALE</span></code></a> environment variables.</p>
<p>Example of customized Python always running in isolated mode:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">int</span> <span class="nf">main</span><span class="p">(</span><span class="kt">int</span> <span class="n">argc</span><span class="p">,</span> <span class="kt">char</span> <span class="o">**</span><span class="n">argv</span><span class="p">)</span>
<span class="p">{</span>
    <span class="n">PyStatus</span> <span class="n">status</span><span class="p">;</span>

    <span class="n">PyConfig</span> <span class="n">config</span><span class="p">;</span>
    <span class="n">PyConfig_InitPythonConfig</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>
    <span class="n">config</span><span class="p">.</span><span class="n">isolated</span> <span class="o">=</span> <span class="mi">1</span><span class="p">;</span>

    <span class="cm">/* Decode command line arguments.</span>
<span class="cm">       Implicitly preinitialize Python (in isolated mode). */</span>
    <span class="n">status</span> <span class="o">=</span> <span class="n">PyConfig_SetBytesArgv</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">,</span> <span class="n">argc</span><span class="p">,</span> <span class="n">argv</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">PyStatus_Exception</span><span class="p">(</span><span class="n">status</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">goto</span> <span class="n">fail</span><span class="p">;</span>
    <span class="p">}</span>

    <span class="n">status</span> <span class="o">=</span> <span class="n">Py_InitializeFromConfig</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">PyStatus_Exception</span><span class="p">(</span><span class="n">status</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">goto</span> <span class="n">fail</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="n">PyConfig_Clear</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>

    <span class="k">return</span> <span class="n">Py_RunMain</span><span class="p">();</span>

<span class="nl">fail</span><span class="p">:</span>
    <span class="n">PyConfig_Clear</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">PyStatus_IsExit</span><span class="p">(</span><span class="n">status</span><span class="p">))</span> <span class="p">{</span>
        <span class="k">return</span> <span class="n">status</span><span class="p">.</span><span class="n">exitcode</span><span class="p">;</span>
    <span class="p">}</span>
    <span class="cm">/* Display the error message and exit the process with</span>
<span class="cm">       non-zero exit code */</span>
    <span class="n">Py_ExitStatusException</span><span class="p">(</span><span class="n">status</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
<div class="section" id="path-configuration">
<span id="init-path-config"></span><h2>Path Configuration<a class="headerlink" href="#path-configuration" title="Permalink to this headline">¶</a></h2>
<p><a class="reference internal" href="#c.PyConfig" title="PyConfig"><code class="xref c c-type docutils literal notranslate"><span class="pre">PyConfig</span></code></a> contains multiple fields for the path configuration:</p>
<ul class="simple">
<li><p>Path configuration inputs:</p>
<ul>
<li><p><a class="reference internal" href="#c.PyConfig.home" title="PyConfig.home"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.home</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig.pathconfig_warnings" title="PyConfig.pathconfig_warnings"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.pathconfig_warnings</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig.program_name" title="PyConfig.program_name"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.program_name</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig.pythonpath_env" title="PyConfig.pythonpath_env"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.pythonpath_env</span></code></a></p></li>
<li><p>current working directory: to get absolute paths</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">PATH</span></code> environment variable to get the program full path
(from <a class="reference internal" href="#c.PyConfig.program_name" title="PyConfig.program_name"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.program_name</span></code></a>)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">__PYVENV_LAUNCHER__</span></code> environment variable</p></li>
<li><p>(Windows only) Application paths in the registry under
“SoftwarePythonPythonCoreX.YPythonPath” of HKEY_CURRENT_USER and
HKEY_LOCAL_MACHINE (where X.Y is the Python version).</p></li>
</ul>
</li>
<li><p>Path configuration output fields:</p>
<ul>
<li><p><a class="reference internal" href="#c.PyConfig.base_exec_prefix" title="PyConfig.base_exec_prefix"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.base_exec_prefix</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig.base_executable" title="PyConfig.base_executable"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.base_executable</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig.base_prefix" title="PyConfig.base_prefix"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.base_prefix</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig.exec_prefix" title="PyConfig.exec_prefix"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.exec_prefix</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig.executable" title="PyConfig.executable"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.executable</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig.module_search_paths_set" title="PyConfig.module_search_paths_set"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.module_search_paths_set</span></code></a>,
<a class="reference internal" href="#c.PyConfig.module_search_paths" title="PyConfig.module_search_paths"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.module_search_paths</span></code></a></p></li>
<li><p><a class="reference internal" href="#c.PyConfig.prefix" title="PyConfig.prefix"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.prefix</span></code></a></p></li>
</ul>
</li>
</ul>
<p>If at least one “output field” is not set, Python calculates the path
configuration to fill unset fields. If
<a class="reference internal" href="#c.PyConfig.module_search_paths_set" title="PyConfig.module_search_paths_set"><code class="xref c c-member docutils literal notranslate"><span class="pre">module_search_paths_set</span></code></a> is equal to 0,
<a class="reference internal" href="#c.PyConfig.module_search_paths" title="PyConfig.module_search_paths"><code class="xref c c-member docutils literal notranslate"><span class="pre">module_search_paths</span></code></a> is overridden and
<a class="reference internal" href="#c.PyConfig.module_search_paths_set" title="PyConfig.module_search_paths_set"><code class="xref c c-member docutils literal notranslate"><span class="pre">module_search_paths_set</span></code></a> is set to 1.</p>
<p>It is possible to completely ignore the function calculating the default
path configuration by setting explicitly all path configuration output
fields listed above. A string is considered as set even if it is non-empty.
<code class="docutils literal notranslate"><span class="pre">module_search_paths</span></code> is considered as set if
<code class="docutils literal notranslate"><span class="pre">module_search_paths_set</span></code> is set to 1. In this case, path
configuration input fields are ignored as well.</p>
<p>Set <a class="reference internal" href="#c.PyConfig.pathconfig_warnings" title="PyConfig.pathconfig_warnings"><code class="xref c c-member docutils literal notranslate"><span class="pre">pathconfig_warnings</span></code></a> to 0 to suppress warnings when
calculating the path configuration (Unix only, Windows does not log any warning).</p>
<p>If <a class="reference internal" href="#c.PyConfig.base_prefix" title="PyConfig.base_prefix"><code class="xref c c-member docutils literal notranslate"><span class="pre">base_prefix</span></code></a> or <a class="reference internal" href="#c.PyConfig.base_exec_prefix" title="PyConfig.base_exec_prefix"><code class="xref c c-member docutils literal notranslate"><span class="pre">base_exec_prefix</span></code></a>
fields are not set, they inherit their value from <a class="reference internal" href="#c.PyConfig.prefix" title="PyConfig.prefix"><code class="xref c c-member docutils literal notranslate"><span class="pre">prefix</span></code></a>
and <a class="reference internal" href="#c.PyConfig.exec_prefix" title="PyConfig.exec_prefix"><code class="xref c c-member docutils literal notranslate"><span class="pre">exec_prefix</span></code></a> respectively.</p>
<p><a class="reference internal" href="#c.Py_RunMain" title="Py_RunMain"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_RunMain()</span></code></a> and <a class="reference internal" href="veryhigh.html#c.Py_Main" title="Py_Main"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_Main()</span></code></a> modify <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>:</p>
<ul class="simple">
<li><p>If <a class="reference internal" href="#c.PyConfig.run_filename" title="PyConfig.run_filename"><code class="xref c c-member docutils literal notranslate"><span class="pre">run_filename</span></code></a> is set and is a directory which contains a
<code class="docutils literal notranslate"><span class="pre">__main__.py</span></code> script, prepend <a class="reference internal" href="#c.PyConfig.run_filename" title="PyConfig.run_filename"><code class="xref c c-member docutils literal notranslate"><span class="pre">run_filename</span></code></a> to
<a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>.</p></li>
<li><p>If <a class="reference internal" href="#c.PyConfig.isolated" title="PyConfig.isolated"><code class="xref c c-member docutils literal notranslate"><span class="pre">isolated</span></code></a> is zero:</p>
<ul>
<li><p>If <a class="reference internal" href="#c.PyConfig.run_module" title="PyConfig.run_module"><code class="xref c c-member docutils literal notranslate"><span class="pre">run_module</span></code></a> is set, prepend the current directory
to <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>. Do nothing if the current directory cannot be read.</p></li>
<li><p>If <a class="reference internal" href="#c.PyConfig.run_filename" title="PyConfig.run_filename"><code class="xref c c-member docutils literal notranslate"><span class="pre">run_filename</span></code></a> is set, prepend the directory of the
filename to <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>.</p></li>
<li><p>Otherwise, prepend an empty string to <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>.</p></li>
</ul>
</li>
</ul>
<p>If <a class="reference internal" href="#c.PyConfig.site_import" title="PyConfig.site_import"><code class="xref c c-member docutils literal notranslate"><span class="pre">site_import</span></code></a> is non-zero, <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> can be
modified by the <a class="reference internal" href="../library/site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code></a> module. If
<a class="reference internal" href="#c.PyConfig.user_site_directory" title="PyConfig.user_site_directory"><code class="xref c c-member docutils literal notranslate"><span class="pre">user_site_directory</span></code></a> is non-zero and the user’s
site-package directory exists, the <a class="reference internal" href="../library/site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code></a> module appends the user’s
site-package directory to <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>.</p>
<p>The following configuration files are used by the path configuration:</p>
<ul class="simple">
<li><p><code class="docutils literal notranslate"><span class="pre">pyvenv.cfg</span></code></p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">python._pth</span></code> (Windows only)</p></li>
<li><p><code class="docutils literal notranslate"><span class="pre">pybuilddir.txt</span></code> (Unix only)</p></li>
</ul>
<p>The <code class="docutils literal notranslate"><span class="pre">__PYVENV_LAUNCHER__</span></code> environment variable is used to set
<a class="reference internal" href="#c.PyConfig.base_executable" title="PyConfig.base_executable"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.base_executable</span></code></a></p>
</div>
<div class="section" id="py-runmain">
<h2>Py_RunMain()<a class="headerlink" href="#py-runmain" title="Permalink to this headline">¶</a></h2>
<dl class="function">
<dt id="c.Py_RunMain">
int <code class="sig-name descname">Py_RunMain</code><span class="sig-paren">(</span>void<span class="sig-paren">)</span><a class="headerlink" href="#c.Py_RunMain" title="Permalink to this definition">¶</a></dt>
<dd><p>Execute the command (<a class="reference internal" href="#c.PyConfig.run_command" title="PyConfig.run_command"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.run_command</span></code></a>), the script
(<a class="reference internal" href="#c.PyConfig.run_filename" title="PyConfig.run_filename"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.run_filename</span></code></a>) or the module
(<a class="reference internal" href="#c.PyConfig.run_module" title="PyConfig.run_module"><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig.run_module</span></code></a>) specified on the command line or in the
configuration.</p>
<p>By default and when if <a class="reference internal" href="../using/cmdline.html#cmdoption-i"><code class="xref std std-option docutils literal notranslate"><span class="pre">-i</span></code></a> option is used, run the REPL.</p>
<p>Finally, finalizes Python and returns an exit status that can be passed to
the <code class="docutils literal notranslate"><span class="pre">exit()</span></code> function.</p>
</dd></dl>

<p>See <a class="reference internal" href="#init-python-config"><span class="std std-ref">Python Configuration</span></a> for an example of
customized Python always running in isolated mode using
<a class="reference internal" href="#c.Py_RunMain" title="Py_RunMain"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_RunMain()</span></code></a>.</p>
</div>
<div class="section" id="multi-phase-initialization-private-provisional-api">
<h2>Multi-Phase Initialization Private Provisional API<a class="headerlink" href="#multi-phase-initialization-private-provisional-api" title="Permalink to this headline">¶</a></h2>
<p>This section is a private provisional API introducing multi-phase
initialization, the core feature of the <span class="target" id="index-8"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0432"><strong>PEP 432</strong></a>:</p>
<ul class="simple">
<li><p>“Core” initialization phase, “bare minimum Python”:</p>
<ul>
<li><p>Builtin types;</p></li>
<li><p>Builtin exceptions;</p></li>
<li><p>Builtin and frozen modules;</p></li>
<li><p>The <a class="reference internal" href="../library/sys.html#module-sys" title="sys: Access system-specific parameters and functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code></a> module is only partially initialized
(ex: <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a> doesn’t exist yet).</p></li>
</ul>
</li>
<li><p>“Main” initialization phase, Python is fully initialized:</p>
<ul>
<li><p>Install and configure <a class="reference internal" href="../library/importlib.html#module-importlib" title="importlib: The implementation of the import machinery."><code class="xref py py-mod docutils literal notranslate"><span class="pre">importlib</span></code></a>;</p></li>
<li><p>Apply the <a class="reference internal" href="#init-path-config"><span class="std std-ref">Path Configuration</span></a>;</p></li>
<li><p>Install signal handlers;</p></li>
<li><p>Finish <a class="reference internal" href="../library/sys.html#module-sys" title="sys: Access system-specific parameters and functions."><code class="xref py py-mod docutils literal notranslate"><span class="pre">sys</span></code></a> module initialization (ex: create <a class="reference internal" href="../library/sys.html#sys.stdout" title="sys.stdout"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.stdout</span></code></a>
and <a class="reference internal" href="../library/sys.html#sys.path" title="sys.path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.path</span></code></a>);</p></li>
<li><p>Enable optional features like <a class="reference internal" href="../library/faulthandler.html#module-faulthandler" title="faulthandler: Dump the Python traceback."><code class="xref py py-mod docutils literal notranslate"><span class="pre">faulthandler</span></code></a> and <a class="reference internal" href="../library/tracemalloc.html#module-tracemalloc" title="tracemalloc: Trace memory allocations."><code class="xref py py-mod docutils literal notranslate"><span class="pre">tracemalloc</span></code></a>;</p></li>
<li><p>Import the <a class="reference internal" href="../library/site.html#module-site" title="site: Module responsible for site-specific configuration."><code class="xref py py-mod docutils literal notranslate"><span class="pre">site</span></code></a> module;</p></li>
<li><p>etc.</p></li>
</ul>
</li>
</ul>
<p>Private provisional API:</p>
<ul class="simple">
<li><p><code class="xref c c-member docutils literal notranslate"><span class="pre">PyConfig._init_main</span></code>: if set to 0,
<a class="reference internal" href="#c.Py_InitializeFromConfig" title="Py_InitializeFromConfig"><code class="xref c c-func docutils literal notranslate"><span class="pre">Py_InitializeFromConfig()</span></code></a> stops at the “Core” initialization phase.</p></li>
</ul>
<dl class="function">
<dt id="c._Py_InitializeMain">
<a class="reference internal" href="#c.PyStatus" title="PyStatus">PyStatus</a> <code class="sig-name descname">_Py_InitializeMain</code><span class="sig-paren">(</span>void<span class="sig-paren">)</span><a class="headerlink" href="#c._Py_InitializeMain" title="Permalink to this definition">¶</a></dt>
<dd><p>Move to the “Main” initialization phase, finish the Python initialization.</p>
</dd></dl>

<p>No module is imported during the “Core” phase and the <code class="docutils literal notranslate"><span class="pre">importlib</span></code> module is
not configured: the <a class="reference internal" href="#init-path-config"><span class="std std-ref">Path Configuration</span></a> is only
applied during the “Main” phase. It may allow to customize Python in Python to
override or tune the <a class="reference internal" href="#init-path-config"><span class="std std-ref">Path Configuration</span></a>, maybe
install a custom <a class="reference internal" href="../library/sys.html#sys.meta_path" title="sys.meta_path"><code class="xref py py-data docutils literal notranslate"><span class="pre">sys.meta_path</span></code></a> importer or an import hook, etc.</p>
<p>It may become possible to calculatin the <a class="reference internal" href="#init-path-config"><span class="std std-ref">Path Configuration</span></a> in Python, after the Core phase and before the Main phase,
which is one of the <span class="target" id="index-9"></span><a class="pep reference external" href="https://www.python.org/dev/peps/pep-0432"><strong>PEP 432</strong></a> motivation.</p>
<p>The “Core” phase is not properly defined: what should be and what should
not be available at this phase is not specified yet. The API is marked
as private and provisional: the API can be modified or even be removed
anytime until a proper public API is designed.</p>
<p>Example running Python code between “Core” and “Main” initialization
phases:</p>
<div class="highlight-c notranslate"><div class="highlight"><pre><span></span><span class="kt">void</span> <span class="nf">init_python</span><span class="p">(</span><span class="kt">void</span><span class="p">)</span>
<span class="p">{</span>
    <span class="n">PyStatus</span> <span class="n">status</span><span class="p">;</span>

    <span class="n">PyConfig</span> <span class="n">config</span><span class="p">;</span>
    <span class="n">PyConfig_InitPythonConfig</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>
    <span class="n">config</span><span class="p">.</span><span class="n">_init_main</span> <span class="o">=</span> <span class="mi">0</span><span class="p">;</span>

    <span class="cm">/* ... customize &#39;config&#39; configuration ... */</span>

    <span class="n">status</span> <span class="o">=</span> <span class="n">Py_InitializeFromConfig</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>
    <span class="n">PyConfig_Clear</span><span class="p">(</span><span class="o">&amp;</span><span class="n">config</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">PyStatus_Exception</span><span class="p">(</span><span class="n">status</span><span class="p">))</span> <span class="p">{</span>
        <span class="n">Py_ExitStatusException</span><span class="p">(</span><span class="n">status</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="cm">/* Use sys.stderr because sys.stdout is only created</span>
<span class="cm">       by _Py_InitializeMain() */</span>
    <span class="kt">int</span> <span class="n">res</span> <span class="o">=</span> <span class="n">PyRun_SimpleString</span><span class="p">(</span>
        <span class="s">&quot;import sys; &quot;</span>
        <span class="s">&quot;print(&#39;Run Python code before _Py_InitializeMain&#39;, &quot;</span>
               <span class="s">&quot;file=sys.stderr)&quot;</span><span class="p">);</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">res</span> <span class="o">&lt;</span> <span class="mi">0</span><span class="p">)</span> <span class="p">{</span>
        <span class="n">exit</span><span class="p">(</span><span class="mi">1</span><span class="p">);</span>
    <span class="p">}</span>

    <span class="cm">/* ... put more configuration code here ... */</span>

    <span class="n">status</span> <span class="o">=</span> <span class="n">_Py_InitializeMain</span><span class="p">();</span>
    <span class="k">if</span> <span class="p">(</span><span class="n">PyStatus_Exception</span><span class="p">(</span><span class="n">status</span><span class="p">))</span> <span class="p">{</span>
        <span class="n">Py_ExitStatusException</span><span class="p">(</span><span class="n">status</span><span class="p">);</span>
    <span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../contents.html">Table of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#">Python Initialization Configuration</a><ul>
<li><a class="reference internal" href="#pywidestringlist">PyWideStringList</a></li>
<li><a class="reference internal" href="#pystatus">PyStatus</a></li>
<li><a class="reference internal" href="#pypreconfig">PyPreConfig</a></li>
<li><a class="reference internal" href="#preinitialization-with-pypreconfig">Preinitialization with PyPreConfig</a></li>
<li><a class="reference internal" href="#pyconfig">PyConfig</a></li>
<li><a class="reference internal" href="#initialization-with-pyconfig">Initialization with PyConfig</a></li>
<li><a class="reference internal" href="#isolated-configuration">Isolated Configuration</a></li>
<li><a class="reference internal" href="#python-configuration">Python Configuration</a></li>
<li><a class="reference internal" href="#path-configuration">Path Configuration</a></li>
<li><a class="reference internal" href="#py-runmain">Py_RunMain()</a></li>
<li><a class="reference internal" href="#multi-phase-initialization-private-provisional-api">Multi-Phase Initialization Private Provisional API</a></li>
</ul>
</li>
</ul>

  <h4>Previous topic</h4>
  <p class="topless"><a href="init.html"
                        title="previous chapter">Initialization, Finalization, and Threads</a></p>
  <h4>Next topic</h4>
  <p class="topless"><a href="memory.html"
                        title="next chapter">Memory Management</a></p>
  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../bugs.html">Report a Bug</a></li>
      <li>
        <a href="https://github.com/python/cpython/blob/3.8/Doc/c-api/init_config.rst"
            rel="nofollow">Show Source
        </a>
      </li>
    </ul>
  </div>
        </div>
      </div>
      <div class="clearer"></div>
    </div>  
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="right" >
          <a href="memory.html" title="Memory Management"
             >next</a> |</li>
        <li class="right" >
          <a href="init.html" title="Initialization, Finalization, and Threads"
             >previous</a> |</li>

          <li><img src="../_static/py.svg" alt="python logo" style="vertical-align: middle; margin-top: -1px"/></li>
          <li><a href="https://www.python.org/">Python</a> &#187;</li>
          <li class="switchers">
            <div class="language_switcher_placeholder"></div>
            <div class="version_switcher_placeholder"></div>
          </li>
          <li>
              
          </li>
    <li id="cpython-language-and-version">
      <a href="../index.html">3.8.13 Documentation</a> &#187;
    </li>

          <li class="nav-item nav-item-1"><a href="index.html" >Python/C API Reference Manual</a> &#187;</li>
                <li class="right">
                    

    <div class="inline-search" role="search">
        <form class="inline-search" action="../search.html" method="get">
          <input placeholder="Quick search" aria-label="Quick search" type="text" name="q" />
          <input type="submit" value="Go" />
          <input type="hidden" name="check_keywords" value="yes" />
          <input type="hidden" name="area" value="default" />
        </form>
    </div>
                     |
                </li>
            
      </ul>
    </div>  
    <div class="footer">
    &copy; <a href="../copyright.html">Copyright</a> 2001-2022, Python Software Foundation.
    <br />
    This page is licensed under the Python Software Foundation License Version 2.
    <br />
    Examples, recipes, and other code in the documentation are additionally licensed under the Zero Clause BSD License.
    <br />
    
    <br />

    The Python Software Foundation is a non-profit corporation.
<a href="https://www.python.org/psf/donations/">Please donate.</a>
<br />
    <br />

    Last updated on Mar 17, 2022.
    <a href="https://docs.python.org/3/bugs.html">Found a bug</a>?
    <br />

    Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 2.4.4.
    </div>

  </body>
</html>